''' 3 - Intelligence artificielle'''

'''3-1 - Algorithme KNN - Reconnaissance de panneaux'''

'''Dossier partagé images: https://www.dropbox.com/sh/2zce39bxxtfcl58/AADVz2oW9QxT-leD-0l3Mopba?dl=0'''

## 3-1 - Algorithme KNN - Reconnaissance de panneaux

## Utilisation de sklearn

# Données

x = Donnees
y = Liste_Dossier
DR = Donnees_R[0]
k = 5

# Apprentissage

from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(k)
knn.fit(x,y)

# Reconnaissance

Sol = knn.predict([DR])[0]
print(Sol)

# Matrice de confusion

from sklearn.metrics import confusion_matrix
y_true = []
y_pred = []
for i in range(N):
    y_true.append(int(LR[i][0]))
    y_pred.append(knn.predict([Donnees_R[i]])[0])
Mat = confusion_matrix(y_true, y_pred)
print(Mat)